package com.kkd.kkdapp.db.app.model;

import com.kkd.kkdapp.db.annotate.EADBField;
import com.kkd.kkdapp.db.annotate.EADBField.EADBFieldType;
import com.kkd.kkdapp.db.app.EADBHelper;
import com.kkd.kkdapp.db.base.EABaseModel;

public class KkdAppInfo extends EABaseModel {
	private static final String TABLE_NAME = KkdAppInfo.class.getSimpleName();

	// 登陆状态 后台运行起始时间
	@EADBField(type = EADBFieldType.Integer)
	public long backgroundTime;
	
	public static long insert(KkdAppInfo appinfo) {
		KkdAppInfo curInfo = EADBHelper.getInstance().queryTopOne(KkdAppInfo.class, null,
				null);
		if (curInfo != null) {
			EADBHelper.getInstance().delete(TABLE_NAME, null, null);
		}

		return EADBHelper.getInstance().saveBindId(appinfo);
	}

	public static KkdAppInfo getKkdAppInfo() {
		KkdAppInfo appinfo = EADBHelper.getInstance()
				.queryTopOne(KkdAppInfo.class, null, null);
		return appinfo;
	}

	public static boolean delCurUser() {
		return EADBHelper.getInstance().delete(TABLE_NAME, null, null) > 0;
	}

}
